package com.example.mybatisdemo1.service.serviceIMPL;

import com.example.mybatisdemo1.entity.User;
import com.example.mybatisdemo1.mapper.UserMapper;
import com.example.mybatisdemo1.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;

    @Override
    public List<User> getAllUser(String type) {
        return  userMapper.getAllUser( type);// 调用接口中的“方法”
    }

    @Override
    public User getUserById(int id) {
        return userMapper.getUserById(id);
    }

    @Override
    public User queryUserByPassword(String username, String password) {
        List<User> userInfos = userMapper.queryUserByPassword(username,password);
        if (userInfos != null && userInfos.size() > 0) {
            return userInfos.get(0);
        }
        return null;
    }


}
